﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SuperMarketSystem
{   
    public partial class SearchLimit : Form
    {
        String typeText = "";//初始化类型字符串
        public SearchLimit(String typeText)
        {
            InitializeComponent();
            this.typeText = typeText;
            if (typeText == "ID")
            {
                type.Text = "ID";
            }
            else if (typeText == "Name")
            {
                type.Text = "名称";
            }
            else
                type.Text = typeText;
        }

        private void btnSubmit_Click(object sender, EventArgs e)//点击提交按钮触发事件
        {
            if (typeText == "ID")
            {
                if (MyOtherUtils.checkInt(limitation.Text))
                {
                    this.Close();
                }
            }
            else if (typeText == "Name")
            {
                this.Close();
            }
            else
            {
                MessageBox.Show("当前输入ID不是非负整数");
            }
        }
        public int returnByID()//返回ID触发函数
        {
            return Convert.ToInt32(limitation.Text);
        }
        public String returnByName()//返回名称触发函数
        {
            return limitation.Text;
        }

        private void SearchLimit_Load(object sender, EventArgs e)
        {

        }
    }
}
